package veilingsite.beans.nl;

import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;

public class BaseBean {
	private DecimalFormat doubleFormat;
	private SimpleDateFormat sdf;
	
	public BaseBean(){
		doubleFormat = new DecimalFormat();
		sdf = new SimpleDateFormat("EEE, d MMM yyyy 'om' HH:mm:ss");
	}
	
	public String formatTimestamp (Timestamp datum){
		return sdf.format(datum);
	}
	
	public String formatDouble(double getal){
		if (getal == 0){
			return "$ 0,-";
		} else if (getal % 1 == 0.0){
			doubleFormat.setMaximumFractionDigits(0);
			return "$ " + doubleFormat.format(getal)+",-";
		} else {
			doubleFormat.setMaximumFractionDigits(2);
			return "$ " + doubleFormat.format(getal);
		}
	}

}
